{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "authorship_tag": "ABX9TyPa6c+rauB1g3Zflwt4PyS2",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/tomasonjo/blogs/blob/master/llm/mem0-neo4j.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "gy1bhoLVCfrK"
      },
      "outputs": [],
      "source": [
        "!pip install --quiet \"mem0ai[graph]\""
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "from getpass import getpass\n",
        "\n",
        "os.environ[\"OPENAI_API_KEY\"] = getpass(\"OpenAI API Key:\")"
      ],
      "metadata": {
        "id": "HTSuCGBkENe8"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from mem0 import Memory\n",
        "\n",
        "config = {\n",
        "    \"graph_store\": {\n",
        "        \"provider\": \"neo4j\",\n",
        "        \"config\": {\n",
        "            \"url\": \"neo4j+s://0ec0791c..neo4j.io\",\n",
        "            \"username\": \"neo4j\",\n",
        "            \"password\": \"\"\n",
        "        }\n",
        "    }\n",
        "}\n",
        "\n",
        "m = Memory.from_config(config_dict=config)"
      ],
      "metadata": {
        "id": "OrNdUxdUCrxg"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "m.add(\"I like skiing in Alps\", user_id=\"Tomaz\")"
      ],
      "metadata": {
        "id": "PdhRyU9yDXQ3"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "xdU9mJEzEugP"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}